#多类型赋值
# obj=1
# print(obj)
# 
# obj="void"
# print(obj)
# 
# obj=True
# print(obj)

#条件判断
# age=18
# if age>=18:
#     print("你是个成年的宝宝了，岁数%s" % age)
#     print("么么哒")
# elif age>=16:
#     print("棒棒的青少年")
# else:
#     print("小朋友")

# sum=0
# for x in [1,2,3,4,5,6,7,8,9,10]:
#     sum = sum + x
# print(sum)

# L=[]
# n=1
# while n<=99:
#     L.append(n)
#     n = n+2
# print(L)
# print(L[0],L[1],L[2])
# print(L[0:5])
# print(L[:5])
# print(L[1:5])
# print(L[-1:])

# L=list(range(100))
# print(L[0:10:2])
# C=L[:]
# print(C)

#字典迭代
# d={"a":1,"b":2,"c":3}
# for key in d:
#     print("键名:%s,键值:%s" % (key,d[key]))
# for k,v in d.items():
#     print("键名:%s,键值:%s" % (k,v))

#字符串迭代
# str = "ABC"
# for s in str:
#     print(s)

#列表生成式
# d={"a":1,"b":2,"c":3}
# print([k+"="+str(v) for k,v in d.items()])
# L=list(range(20))
# #在for后面的if是筛选不能有else
# print([i for i in L if i%2==0])
# #在for前面的是表达式要if else
# print([i if i%2==0 else -i for i in L])

#生成器,保存的是算法，没有保存实际数据到内存
# g = (x for x in range(10))
# print(next(g))

#map  第一个参数是函数，第二个是Iterable,返回值是Iterator,惰性序列
# def f(x):
#     return x * x
# r = map(f,[1,2,3,4,5])
# print(list(r))

#reduce 可以将结果不断累加，1+3+5+7+9
# from functools import reduce
# def add(x,y):
#     return x+y
# print(reduce(add,[1,3,5,7,9]))

#排序
# sorted([2,1,0,6,4])
# print(sorted([2,1,0,-6,4], key=abs))
# #字母排序忽略大小写
# sorted(['tom','Ana','Mark'],key=str.lower)
# #逆序字符排序忽略大小写
# sorted(['tom','Ana','Mark'],key=str.lower,reverse=True)

#lambda 匿名函数
a=list(map(lambda x: x*x , [1,2,3,4,5]))
print(a)